﻿using ServerControl.Model.Enum;
using SqlSugar;
using System;
using System.Collections.Generic;

namespace ServerControl.Model
{
	[SugarTable(tableName: "sys_user")]
	public class User
	{
		[SugarColumn(IsPrimaryKey = true)]
		public string UserName { get; set; }
		public string Password { get; set; }
		/// <summary>
		/// 角色（1管理员，2用户）
		/// </summary>
		public Role Role { get; set; }
		public DateTime ExpireDate { get; set; }
		/// <summary>
		/// 令牌（用户从web端登陆时更新此值）
		/// </summary>
		public string Token { get; set; }
		/// <summary>
		/// 用户代码（设备链接验证用）
		/// </summary>
		public string Code { get; set; }
		/// <summary>
		/// 是否启用
		/// </summary>
		public bool IsEnable { get; set; }
		/// <summary>
		/// 最大设备量
		/// </summary>
		public int MaxCount { get; set; }
		/// <summary>
		/// 是否过期
		/// </summary>
		[SugarColumn(IsIgnore = true)]
		public bool IsExpired { get { return ExpireDate <= DateTime.Now; } }

		[SugarColumn(IsIgnore = true)]
		public List<Model.Command> Commands { get; set; }
		public string LastLoginIp { get; set; }
		public DateTime LastLoginTime { get; set; }
		/// <summary>
		/// 独占数据条数
		/// </summary>
		public int OnlyData { get; set; }
        /// <summary>
        /// 独占数据模式，0不能页面添加
        /// </summary>
        public int OnlyDataMode { get; set; }
        /// <summary>
        /// 共享数据条数
        /// </summary>
        public int ShareData { get; set; }

        /// <summary>
        /// 共享数据模式，0不能页面添加
        /// </summary>
        public int ShareDataMode { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
		public DateTime AddTime { get; set; }
	}
}
